<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>APP版本管理</title>
	<jsp:include page="../../import.jsp" flush="true" />
	<script type="text/javascript">
		var grid = null;
		var callback = function () {
			grid.reload();
		};
		$(function () {
			initForm();
			initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
			searchBtnEvent();
			clearBtnEvent();
		});

		//清空按钮事件
		function clearBtnEvent(){
			$("#clearBtn").click(function(event) {
				clearLigerForm("searchBar");
			});
		}

		//初始化表单
		function initForm(){
			$("#searchBar").ligerForm();
		}

		//查询按钮事件
		function searchBtnEvent(){
			$("#searchBtn").click(function(event) {
				var form = new liger.get("searchBar");
				var data = form.getData();
				for (name in data){
					grid.setParm(name,data[name]);
				};
				grid.reload();
			});
		}

		//初始化列表
		function initGrid(){
			$("#ligergrid1").ligerGrid({
				url: '<%=path%>/upgrade/sysAppVerCfg/initSysAppVerCfgList.do',
				method : 'get',
				columns: [
					{ display: '系统', name: 'sysCd', width: 150 , enabledSort:true},
					{ display: 'APP类型', name: 'opTypCd', width: 80 , enabledSort:true},
					{ display: '新版本号', name: 'verId', width: 80 , enabledSort:true},
					{ display: '显示版本号', name: 'verNo', width: 80 , enabledSort:true},
                    { display: '版本说明', name: 'verDscr', minWidth: 200 , isEllipsis: false, enabledSort:true,render:function (i,o,v ) {

                            return SqHTMLDecodeString(v);
                        }},
					{ display: '新版本下载地址', name: 'instFileUrl', minWidth: 400 , isEllipsis: false, enabledSort:true},
					{ display: '发布时间', name: 'relDt', width: 100 , render:renderDate, enabledSort:true},
					{ display: '更新类型', name: 'isForceUpdateNm', width: 80 , enabledSort:true},
					{
						display: '操作',width: 150,
						render: function (rowdata, rowindex, value){
							var h1 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="modifysysapp('+rowdata.id+')"><i class="sqBtnIco_4"></i>修改</a>'
							var h2 = '<a class="sq-button-hasicon" href="javascript:void(0);" onclick="removesysapp('+rowdata.id+')"><i class="sqBtnIco_7"></i>删除</a>';
							return h1+h2;
						}
					}
				],
				pageSize:10,
				root:'rows',
				record:'total',
				rownumbers: true,
				hideLoadButton : true,
				width: '100%',
				height:'100%',
				heightDiff:-2,
				fixedCellHeight: false
			});
			grid = liger.get("ligergrid1");
			grid.setHeight(100);
		}

		//格式化时间
		function renderDate(rowdata, index, value){
			var dateStr = "";
			if(null != value){
				var date = new Date(value);
				dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
			}
			return dateStr;
		}
		//修改
		function modifysysapp(id){
			var tit = '新增版本内容';
			var tabid='AddSysAppVerCfg';
			if(id!=''){
				tit = '修改版本内容';
				tabid='ModifySysAppVerCfg'+id;
			}
			Add_navTab(tabid, tit, '<%=path%>/upgrade/sysAppVerCfg/modifySysAppVerCfgPage.do?id='+id, callback);
		}
		function getVerId(){
            $.ajax({
                type: 'post',
                dataType:'json',
				data:{},
                url: '<%=path%>/upgrade/sysAppVerCfg/getVerId.do',
                success:function(msg){
                    if(msg.success == 1){
						$.ligerDialog.alert("您本次发版的升级版本号为：" + msg.data);
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
		}
		//删除
		function removesysapp(id){
			$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
				if(flag == false)return;
				var wait_dialog;
				$.ajax({
					type: 'post',
					dataType:'json',
					data:{id:JSON.stringify(id)},
					url: '<%=path%>/upgrade/sysAppVerCfg/removeSysAppVerCfg.do',
					beforeSend: function(){
						wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
					},
					success:function(msg){
						wait_dialog.close();
						if(msg.success == 1){
							$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
							grid.reload();
						}else{
							$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
						}
					}
				});
			});
		}

	</script>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
			<div class="fieldset1 tabel_col clearFix">
				<div class="fieldBox col_33">
					<div class="label">系统</div>
					<div class="field">
						<select name="sysCd" id="sysCd">
							<option value=" " >请选择</option>
							<c:forEach items="${syscdlist }" var="syscdop">
								<option value="${syscdop.key }">${syscdop.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_33">
					<div class="label">APP类型</div>
					<div class="field">
						<select name="opTypCd" id="opTypCd">
							<option value=" " >请选择</option>
							<c:forEach items="${optypcdlist }" var="optypcdop">
								<option value="${optypcdop.key }">${optypcdop.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
			</div>
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
               <span id="clearBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_19"></i>清空</span>
			   <span id="addBtn" class="sq-button sq-button-hasicon" onclick="modifysysapp('')"><i class="sqBtnIco_3"></i>新增</span>
			   <span id="getBtn" class="sq-button sq-button-hasicon" onclick="getVerId()"><i class="sqBtnIco_10"></i>获取升级版本号</span>
               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
            </div>
        </form>
    </div>
	<div id="ligergrid1" class="sq-grid"></div>
</div>
</body>
</html>